Add roundtrip ckpt conversion tests in CI#3909
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
592aedf to
e6fcf3a
Compare
shuningjin
left a comment
There was a problem hiding this comment.
Looks good! Some minor comments.
| "weight_dtype=bfloat16", | ||
| "hardware=cpu", | ||
| "skip_jax_distributed_system=True", | ||
| "--override_model_architecture=True", |
There was a problem hiding this comment.
unrelated to this pr, for follow-up: I wonder if --override_model_architecture=True can be directly replaced with override_model_config=True
There was a problem hiding this comment.
IIUC override_model_config is for overriding MaxText models, while override_model_architecture is for overriding/dumping HF config.json. I also agree we should consolidate this flag in a follow up PR.
4683db9 to
4f2de47
Compare
🤖 CI Failure Investigation Report (Automated)I have analyzed the recent test failures that occurred after this PR was merged. Findings: Representative Failure:
Recommended Fix: See |
🤖 CI Failure Investigation ReportI have analyzed the recent test failures in the CI pipeline and identified the following: 🔍 What Failed
🪵 Error Details & Stack Trace# Representative traceback from to_maxtext.py (inferred from code analysis and automated triage)
File "src/maxtext/checkpoint_conversion/to_maxtext.py", line 945, in _eager_getter
if v.dtype == torch.bfloat16:
AttributeError: 'NoneType' object has no attribute 'bfloat16'💡 Root Cause Analysis & ContextConfidence: High The failure was caused by unguarded accesses to Additionally, some calls to 🛠️ Recommended FixI have applied a fix to
# Example of the fix applied:
if torch and hasattr(v, "dtype") and v.dtype == torch.bfloat16:
v = v.to(torch.float32)
if hasattr(v, "numpy"):
v = v.numpy()
return v.astype(ml_dtypes.bfloat16) |
🤖 CI Failure Investigation ReportI have analyzed the recent test failures in the CI pipeline and identified the following: 🔍 What Failed
🪵 Error Details & Stack Trace# The failure occurs in environments where torch is not available.
# torch is imported as None via _lazy_import("torch").
# At line 945 (and other locations), the code attempts to access torch.bfloat16.
File "src/maxtext/checkpoint_conversion/to_maxtext.py", line 945, in _eager_getter
if v.dtype == torch.bfloat16:
AttributeError: 'NoneType' object has no attribute 'bfloat16'💡 Root Cause Analysis & ContextConfidence: High The root cause is the lack of guards around Furthermore, 🛠️ Recommended FixI have applied a fix to
# Example of the fix applied:
if torch and hasattr(v, "dtype") and v.dtype == torch.bfloat16:
v = v.to(torch.float32)
if hasattr(v, "numpy"):
v = v.numpy()
return np.array(v).astype(ml_dtypes.bfloat16) |
Description
import torchlazy import into_maxtext, so we can run torch-free conversion in CI.-- We lazy-load safetensors so only 2-out-of-16 chunks were actually loaded for
to_maxtextconversion.-- Within the tmpdir, we convert maxtext Orbax ckpt back to HF for
to_huggingfaceconversion.-- All converted MaxText/HF ckpts will be auto removed from tmpdir.
-- Success criteria: (1) Subprocess finishes without errors (2) Result ckpts exist in the tmpdir. We didn't enforce logits check in the CI because that will actually require torch dependency. But I've tested forward_pass_logit_checker offline.
Tests
2-layerd mini checkpoint with matching gibberish logits: Logs
Tests active in CI: https://screenshot.googleplex.com/4ZhRPiqJZLxTXk5
For this single test on my v5p-8 VM, it took ~2.5 minutes and the peak memory was ~12G.
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.